package com.zjhd.sealcutting.service.impl;

import com.zjhd.sealcutting.dao.AreaMapper;
import com.zjhd.sealcutting.domain.Area;
import com.zjhd.sealcutting.service.AreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * TODO  地区表
 *
 * @author wangchao
 * @version 1.0
 * @date 2020/11/20 14:18
 */
@Service
public class AreaServiceImpl implements AreaService {

    @Autowired
    private AreaMapper areaMapper;

    /**
     * TODO 根据地区id和层级获取地区
     * @author wangchao
     * @date 2020/11/20 14:37
     * @param 
     * @return 
     */
    @Override
    public List<Area> queryParamArea(Integer parentId, Integer level) {
        List<Area> areaList=new ArrayList<>();
        if(parentId==null && level==null){
            areaList=areaMapper.queryProvinceArea();
        }else {
            areaList=areaMapper.queryByParentIdAndLevelArea(parentId,level);
        }
        return areaList;
    }
}
